import { createReducer } from '@reduxjs/toolkit';

import {
    changeTheme,
    login
} from './actions';

interface UserState {
    theme: string;
    token: string | null;
}

const initialState: UserState = { 
    theme: 'Dark',
    token: null
 }

const counterReducer = createReducer(initialState, (builder) => {
    builder
    .addCase(changeTheme, (state, action) => {
        state.theme = action.payload.theme
    })
    .addCase(login, (state, action) => {
        state.token = action.payload.token
    })
})

export default counterReducer